FROM registry.openanolis.cn/openanolis/anolisos:23

LABEL \
    maintainer="OpenAnolis AI SIG" \
    org.opencontainers.image.title="pytorch with zendnn" \
    org.opencontainers.image.version="1.12-23-zendnn4.0"

# install torch
RUN dnf install python3-pip python3-typing-extensions python3-numpy gperftools-libs -y
RUN pip install torch==1.12 -i https://pypi.openanolis.cn/prod/simple
# install torchvision
RUN dnf install python3-requests python3-pillow python3-idna python3-urllib3 python3-certifi python3-charset-normalizer -y
RUN pip install torchvision==0.13.0+cpu -i https://pypi.openanolis.cn/prod/simple

COPY Notices_Licenses_PT_v1.12_ZenDNN_v4.0.txt /
RUN echo "/usr/lib64/libtcmalloc.so.4" >> /etc/ld.so.preload && \
    echo "export OMP_NUM_THREADS=\$(nproc --all)" >> /etc/profile.d/env.sh && \
    echo "export GOMP_CPU_AFFINITY=0-\$(( \$(nproc --all) - 1 ))" >> /etc/profile.d/env.sh

CMD ["/bin/bash"]
